<template>
  <div class="rang-list">
    <!-- 官方榜 -->
    <div class="official">
      <div class="official-top">官方榜</div>
      <div class="official-class-wrap flex">
        <RankClass v-for="(item,index) in officialClassIdList" :key="index" :cards="item"></RankClass>
      </div>
    </div>
    <!-- 全球榜 -->
    <div class="global">
      <div class="global-top">全球榜</div>
      <div class="class-wrap flex">
          <div class="item" v-for="item in globalClassList" :key="item.id">
            <div class="item-top">
              <!-- 累计播放 -->
              <div class="playcount">
                <i class="el-icon-headset"></i>
                {{ item.playCount | changToWan}}
              </div>
              <!-- 图片 -->
              <img :src="item.coverImgUrl" alt="" />
              <!-- 播放图标 -->
              <div class="play"><i class="el-icon-video-play"></i></div>
            </div>
            <div class="bottom">
              {{ item.name }}
            </div>
          </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getRankList , getOfficialRankListDetails} from "@/network/ranklist";
import {changToWan} from "@/common/filter";
import RankClass from "@/views/recommend/RankClass";
export default {
  name: "Ranklist",
  data(){
    return{
      globalClassList: [],
      officialClassIdList: []
    }
  },
  created(){
    this.getGlobalClassList();
  },
  methods: {
    // 获取全球榜单分类
    getGlobalClassList(){
      getRankList('/toplist').then(res=>{
        // console.log(res);
        this.globalClassList = res.list;
      })
    }
    
  },
  filters:{
    changToWan
  },
  components: {
    RankClass
  },
  watch:{
    globalClassList: function(val){
      this.officialClassIdList = [];
      for(let i = 0 ; i < 6 ; i++){
        this.officialClassIdList.push(val[i])
      }
    }
  }
};
</script>

<style scoped lang="less">
.rang-list{
  //官方榜样式
  .official{
    .official-top{
      font-size: 20px;
      height: 30px;
      border-bottom: 1px solid gray;
    }
    .official-class-wrap{
      padding: 0 60px;
    }
  }

  // 全球榜样式
  .global{
    .global-top{
      font-size: 20px;
      height: 30px;
      border-bottom: 1px solid gray;
    }
    .class-wrap{
      .item{
        width: 200px;
        margin-top: 20px;
        overflow: hidden;
        .item-top{
          position: relative;
          img{
            max-width: 200px;
          }
          .playcount{
            position: absolute;
            top: 0;
            right: 0;
            color: #ffffff;
            background-color: rgba(0,0,0,0.3);
            
          }
          .play{
            position: absolute;
            right: 20px;
            bottom: 30px;
            transform: translateX(150%);
            transition: transform .3s cubic-bezier(0.075, 0.82, 0.165, 1);
            .el-icon-video-play{
              width: 36px;
              height: 36px;
              font-size: 36px;
              color: red;
            }
          }
          .play:hover{
            cursor: pointer;
          }
        }
      }
      .item:hover .play{
        transform: translateX(0);
      }
    }
  }
}

</style>